# # 定义animal类
# class Animal():
#
#     def __init__(self, name):
#         self.name = name
#
#     def walk(self):
#         print(self.name + " is walking")
#
#
# # Dog继承animal
# class Dog(Animal):
#     pass
#
#
# # cat继承animal
# class Cat(Animal):
#     pass
#
#
# # Dog和cat均因为继承animal而获得walk的能力和属性
# dog = Dog("Dog")
# dog.walk()
# print('当前的小动物是:', dog.name)
# print('---------------------')
# cat = Cat("Cat")
# cat.walk()
# print('当前的小动物是:', cat.name)


# 子类可以有自己的属性和方法
# 定义animal类
# class Animal():
#
#     def __init__(self, name):
#         self.name = name
#
#     def walk(self):
#         print(self.name + " is walking")
#
#
# # Dog继承animal
# class Dog(Animal):
#     # Dog有吠叫的功能
#     def bark(self):
#         print(self.name + " is bark")
#
#
# dog = Dog("Dog")
# print(dog.name)
# dog.walk()
# dog.bark()

# 子类具备父类所有的属性与功能，但是父类并不具备子类的属性与功能

# 定义animal类
# class Animal():
#     def __init__(self, name):
#         self.name = name
#
#     def walk(self):
#         print(self.name + " is walking")
#
#
# # Dog继承animal
# class Dog(Animal):
#     def bark(self):
#         print(self.name + " is bark")
#
#
# animal = Animal("animal")
# dog = Dog("Dog")
# print(isinstance(dog, Animal))
# print(isinstance(animal, Dog))


# 当子类有自己的构造方法时，将会覆盖父类的构造方法
# # 定义animal类
# class Animal():
#     def __init__(self):
#         print("Animal")
#
#
# # Dog继承animal
# class Dog(Animal):
#     def __init__(self):
#         print("Dog")
#
#
# dog = Dog()

# 子类重写父类方法
# 定义animal类
# class Animal():
#     def __init__(self):
#         print("Animal")
#
#     def eat(self, name):
#         print("Animal is eating")
#
#
# # Dog继承animal
# class Dog(Animal):
#     def __init__(self):
#         print("Dog")
#
#     def eat(self, name):
#         print("Dog is eating \n" + "it's name is:" + name)
#
#
# dog = Dog()
# dog.eat("aimy")

# 问题：

# 定义animal类
class Animal():
    def __init__(self, name):
        self.name = name


# Dog继承animal
class Dog(Animal):
    def __init__(self):
        print("Dog")


dog = Dog()
print(dog.name)
